/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package towerdefence.model.level;

import java.util.ArrayList;
import java.util.List;
import net.phys2d.math.Vector2f;
import net.phys2d.raw.StaticBody;
import net.phys2d.raw.shapes.Line;

/**
 *
 * @author Andreas
 */
public abstract class Level {

    private List<Vector2f> groundControlPoints = new ArrayList<Vector2f>();
    private List<StaticBody> walls = new ArrayList<StaticBody>();
    private List<StaticBody> ground;;
    
    public List<Vector2f> getGroundControlPoints() {
        return groundControlPoints;
    }
    
    public List<StaticBody> getGroundBodies() {
        if(ground != null) {
            return ground;
        }
        ground = new ArrayList<StaticBody>();
        
        for (int i = 0; i < groundControlPoints.size() - 1; i++) {
            Vector2f start = groundControlPoints.get(i);
            Vector2f end = groundControlPoints.get(i + 1);
            Line l = new Line(end.getX() - start.getX(), end.getY() - start.getY());
            StaticBody sb = new StaticBody(l);
            sb.adjustPosition(start);
            ground.add(sb);
        }
        return ground;
    }
    
    protected void addGroundControlPoint(float x, float y) {
        groundControlPoints.add(new Vector2f(x, y));
    }
    
    protected void addWall(StaticBody body) {
        walls.add(body);
    }
}
